package com.ss.android.image;

import android.content.Context;

import com.bytedance.common.utility.UIUtils;
import com.bytedance.common.utility.io.NetHackDbg;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.permission.PermissionsResultAction;
import com.ss.android.common.util.ToolUtils;

import java.io.File;

final class e extends PermissionsResultAction {
    private final BaseImageManager e;
    private final Context a;
    private final File b;
    private final String c;
    private final String d;

    e(BaseImageManager arg1, Context arg2, File arg3, String arg4, String arg5) {
        this.e = arg1;
        this.a = arg2;
        this.b = arg3;
        this.c = arg4;
        this.d = arg5;
    }

    public final void onGranted() {
        int v9 = R.string.toast_download_successful;
        int v8 = R.drawable.close_popup_textpage;
        if (! BaseImageManager.isExternalStorageMounted()) {
            UIUtils.showImageToast(this.a, v8, R.string.toast_download_sdcard_unavail);
        } else {
            String v0 = this.d +  BaseImageManager.getSuffix(this.b.getAbsolutePath(), this.c);
            String v1 = this.e.mExternalFunnyImageDir;
            v0 = v1.endsWith("/") ? v1 + v0 : v1 + "/" + v0;
            File v2 = new File(v0);
            if ((v2.isFile()) && this.b.length() == v2.length()) {
                UIUtils.showImageToast(this.a, v8, v9);
                return;
            }

            if (!NetHackDbg.a(this.b.getAbsolutePath(), v1, v2.getName())) {
                UIUtils.showImageToast(this.a, v8, R.string.toast_download_failed);
                return;
            }

            ToolUtils.sendMediaScannerScanFileBroadcast(this.a, v0);
            UIUtils.showImageToast(this.a, R.drawable.doneicon_popup_textpage, v9);
        }
    }

    public final void onDenied(String arg1) {
    }
}

